class Paging{
    constructor(){
        //this.data = data;
        this.ul = document.querySelector("main .center ul");
        this.url = "http://localhost/ylf/json/list.json"
        //console.log(this.ul)
        this.init();
    }
    init(){
        ajax({
            url:this.url,
        }).then((data)=>{
            this.data = JSON.parse(data);
            this.displaySet();
        })
        
    }
    displaySet(){
        //console.log(this.data)
        let str = "";
        for(let i=0;i<this.data.length; i++){
            str += `<li index = "${this.data[i].goodsId}">
                        <a href = "../page/Detail.html?id=${this.data[i].goodsId}">
                        <img src="${this.data[i].img.largeImg[0]}">
                        <span>￥${this.data[i].span}</span>
                        <s>${this.data[i].s}</s>
                        <p>${this.data[i].p}<em>${this.data[i].em}</em></p>
                        </a>
                    </li>`
        }
        this.ul.innerHTML = str;
        console.log(this.data)



        new Page({
            length:this.data.length,
            data:this.data,
            num:5,
            prev:document.getElementById("prev"),
            next:document.getElementById("next"),
            pageList:document.getElementById("pageList"),
            index:0,
            cont:this.ul
        });
        
    }
}
new Paging();